<HTML>
<HEAD>
<TITLE>
XMLResource.h
</TITLE>
</HEAD>
<BODY>
<PRE>
<font color="green">/*
* Copyright 2006 the original author or authors.
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*      http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</font>

<font color="blue">#ifndef</font> AUTUMN_XMLRESOURCE_H
<font color="blue">#define</font> AUTUMN_XMLRESOURCE_H

<font color="blue">#include</font> <font color="maroon">&#60;vector&#62;</font>
<font color="blue">#include</font> <font color="maroon">&#60;string&#62;</font>
<font color="blue">#include</font> <font color="maroon">"xmlParser.h"</font>
<font color="blue">#include</font> <font color="maroon">"IResource.h"</font>
<font color="blue">#include</font> <font color="maroon">"AutumnDefinition.h"</font>

<font color="blue">namespace</font> Autumn<font color="black">{</font>

<font color="green">/** 
 * Parse XML configuration file
 * @version 0.1.0
 * @since 2006-12-18
 */</font>
<font color="blue">class</font> XMLResource<font color="black">:</font> <font color="blue">public</font> IResource<font color="black">{</font>
<font color="blue">private</font><font color="black">:</font>
    <font color="green">/** All libraries configuration */</font>
    vector<font color="black">&#60;</font>TLibrary<font color="black">*</font><font color="black">&#62;</font> LibsConfig;

    <font color="green">/** Parse library */</font>
    <font color="blue">void</font> parseLibrary<font color="black">(</font>XMLNode<font color="black">&</font> xml, TLibrary<font color="black">&</font> lib<font color="black">)</font>;

    <font color="green">/** Parse bean */</font>
    <font color="blue">void</font> parseBean<font color="black">(</font>XMLNode<font color="black">&</font> xml, TBean<font color="black">&</font> bean<font color="black">)</font>;

    <font color="green">/** Parse Property */</font>
    <font color="blue">void</font> parseProperty<font color="black">(</font>XMLNode<font color="black">&</font> xml, TProperty<font color="black">&</font> prop, <font color="blue">bool</font> isProp<font color="black">)</font>;

    <font color="green">/** Get parsing error message */</font>
    string getErrorMsg<font color="black">(</font>XMLResults<font color="black">&</font> err, <font color="blue">const</font> <font color="blue">char</font><font color="black">*</font> tag<font color="black">)</font>;

    <font color="green">/** convert value to true or false */</font>
    <font color="blue">bool</font> boolAttribute<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> value, <font color="blue">const</font> string<font color="black">&</font> <font color="blue">name</font><font color="black">)</font>;
<font color="blue">public</font><font color="black">:</font>
    <font color="green">/** 
     * Constructor, parse XML file 
     * @param path XML file path
     */</font>
    XMLResource<font color="black">(</font><font color="blue">const</font> <font color="blue">char</font><font color="black">*</font> path<font color="black">)</font>;

    <font color="green">/** Destructor */</font>
    ~XMLResource<font color="black">(</font><font color="black">)</font><font color="black">{</font>
        <font color="blue">for</font><font color="black">(</font><font color="blue">int</font> i<font color="black">=</font><font color="maroon">0</font>; i<font color="black">&#60;</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>LibsConfig.size<font color="black">(</font><font color="black">)</font>; i<font color="black">+</font><font color="black">+</font><font color="black">)</font>
            <font color="blue">delete</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>LibsConfig<font color="black">[</font>i<font color="black">]</font>;
    <font color="black">}</font>

    <font color="green">/** Return all libraries configuration */</font>
    <font color="blue">const</font> vector<font color="black">&#60;</font>TLibrary<font color="black">*</font><font color="black">&#62;</font><font color="black">*</font> getLibraries<font color="black">(</font><font color="black">)</font> <font color="blue">const</font><font color="black">{</font>
        <font color="blue">return</font> <font color="black">&</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>LibsConfig;
    <font color="black">}</font>
<font color="black">}</font>;

<font color="black">}</font> <font color="green">// End namespace Autumn</font>
<font color="blue">#endif</font>

</PRE>
</BODY>
</HTML>
